package com.itheima.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class TimeAspect2 {
    @Around("execution(* com.itheima.service.impl.*.*(..))")
    public Object time(ProceedingJoinPoint pij) throws Throwable {

        long start = System.currentTimeMillis();

        Object proceed = pij.proceed();

        long end = System.currentTimeMillis();

        System.out.println(pij + "方法执行所用的时间"+(end-start) + "ms");
        log.info(pij.getSignature()+"方法执行所用的时间 {} ms",(end-start));
        return proceed;
    }
}
